/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
var search = function(nums, target) {
    let left = 0, right = nums.length - 1;
    while (left <= right) {
        let mid = Math.floor((left + right) / 2);
        let n = nums.at(mid)
        if (n === target) {
            return mid
        }else if (target > n) {
            left = mid + 1
        } else if (target < n) {
            right = mid - 1
        }
    }
    return -1;
};